import Vue from 'vue';
import VueRouter from 'vue-router';
import Home from '../views/all.vue';

Vue.use(VueRouter);
//解决编程式路由往同一地址跳转时会报错的情况
const originalPush = VueRouter.prototype.push;
const originalReplace = VueRouter.prototype.replace;
//push
VueRouter.prototype.push = function push(location, onResolve, onReject) {
  if (onResolve || onReject)
    return originalPush.call(this, location, onResolve, onReject);
  return originalPush.call(this, location).catch(err => err);
};
//replace
VueRouter.prototype.replace = function push(location, onResolve, onReject) {
  if (onResolve || onReject)
    return originalReplace.call(this, location, onResolve, onReject);
  return originalReplace.call(this, location).catch(err => err);
};

const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home,
  },
  {
    path: '/project',
    name: 'project',
    component: () =>
      import('../views/all.vue'),
  },
  // 404页面
  {
    path: '/404',
    name: '404',
    component: () => import('../views/404.vue'),
  },
  {
    path: '/all',
    name: 'all',
    component: () => import('../views/all.vue'),
    children: [
      {
        path: 'general',
        name: 'general',
        component: () => import('../views/general.vue'),
      },
      {
        path: 'dashboard',
        name: 'dashboard',
        component: () => import('../views/dashboard/index.vue'),
      },
      {
        path: 'backlog',
        name: 'backlog',
        component: () => import('../views/approval/backlog/list.vue'),
      },
      {
        path: 'donelog',
        name: 'donelog',
        component: () => import('../views/approval/donelog/list.vue'),
      },
      {
        path: 'overtInfo',
        name: 'overtInfo',
        component: () => import('../views/overtInfo/overtInfo/list.vue'),
      },
      {
        path: 'announce',
        name: 'announce',
        component: () => import('../views/overtInfo/announce/list.vue'),
      },
      {
        path: 'projectdata',
        name: 'projectdata',
        component: () => import('../views/xmzy/zlgl/list.vue'),
      },
      {
        path: 'apiinterface',
        name: 'apiinterface',
        component: () => import('../views/xmzy/api/list.vue'),
      },
      {
        path: 'configMenu',
        name: 'configMenu',
        component: () => import('../views/xmzy/configMenu/list.vue'),
      },
      {
        path: 'usersmanual',
        name: 'usersmanual',
        component: () => import('../views/xmzy/manual/list.vue'),
      },
      {
        path: 'datadictory',
        name: 'datadictory',
        component: () => import('../views/xmzy/dictory/list.vue'),
      },
      {
        path: 'markdown',
        name: 'markdown',
        component: () => import('../views/xmzy/template/list.vue'),
      },
      {
        path: 'myfile',
        name: 'myfile',
        component: () => import('../views/ggzy/grwd/list.vue'),
      },
      {
        path: 'recyclebin',
        name: 'recyclebin',
        component: () => import('../views/ggzy/hsz/list.vue'),
      },
      {
        path: 'projectmanage',
        name: 'projectmanage',
        component: () => import('../views/jcgl/projectmanage/list.vue'),
      },
      {
        path: 'catalogmanage',
        name: 'catalogmanage',
        component: () => import('../views/jcgl/catalogmanage/list.vue'),
      },
      {
        path: 'statistical',
        name: 'statistical',
        component: () => import('../views/statistical/index1.vue'),
      },
      {
        path: 'ggzy/gjjs',
        name: 'ggzy/gjjs',
        component: () => import('../views/ggzy/gjjs/list.vue'),
      },
      {
        path: 'notice',
        name: 'notice',
        component: () => import('../views/jcgl/notice/list.vue'),
      }
    ],
  }
];
const router = new VueRouter({
  routes,
});

export default router;
